﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using B2B.Models;

namespace B2B.Controllers
{
    public class FilesController : Controller
    {
        //
        // GET: /Files/

        public FileDownloadResult Download(string file)
        {
            try
            {
                var fileData = file.GetFileData(Server.MapPath("~/Content/Files"));
                return new FileDownloadResult(file, fileData);
            }
            catch (FileNotFoundException)
            {
                throw new HttpException(404, "File not found.");
            }
        }

    }
}
